package com.tools.scanner.ui.qrcode.creator.impl

import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.tools.scanner.R
import com.tools.scanner.databinding.FragmentContactInputBinding
import com.tools.scanner.utils.ToastUtil

class CreateContactFragment : BaseCreateFragment() {

    private lateinit var mBinding: FragmentContactInputBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        mBinding = FragmentContactInputBinding.inflate(layoutInflater)
        return mBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    }

    override fun createQrCodeContent(): String {
        return """
            BEGIN:VCARD
            VERSION:4.0
            FN:${mBinding.etName.text}
            ORG:${mBinding.etCompany.text}
            TITLE:${mBinding.etTitle.text}
            ADR:${mBinding.etAddress.text}
            TEL;TYPE=WORK;VOICE:${mBinding.etPhone.text}
            TEL;TYPE=CELL;VOICE:${mBinding.etCallPhone.text}
            TEL;FAX:${mBinding.etFax.text}
            NOTE:${mBinding.etNotes.text}
            EMAIL;WORK;INTERNET:${mBinding.etEmail.text}
            END:VCARD
            """.trimIndent()
    }

    override fun checkParams(): Boolean {
        if (TextUtils.isEmpty(mBinding.etName.text.toString())) {
            ToastUtil.showToast(R.string.input_type_check_name)
            return false
        }
        return true
    }


}